ihelpuoo.dom.getParentNodeByName = function(ele,tagName)
{
	if(!ele.parentNode)
		return null;
	if(ele.parentNode.tagName == tagName)
		return ele.parentNode;
	return ihelpuoo.dom.getParentNodeByName(ele.parentNode,tagName);
}

ihelpuoo.dom.createSimpleElement = function(name,className,text)
{
	var ele = document.createElement(name);
	if(className)
		ele.className = className;
	if(text)
		ele.innerHTML = text;
	return ele;
}

ihelpuoo.dom.insertRow = function(table,className)
{
	if(!table) return null;
	var tr = table.insertRow(table.rows.length);
	if(className) tr.className = className;
	return tr;
}

ihelpuoo.dom.insertCell = function(row,className,content)
{
	if(!row) return null;
	var td = null;
	td = row.insertCell(row.cells.length);
	if(className)
		td.className = className;
	if(content)
		td.innerHTML = content;
	
	return td;
}

ihelpuoo.dom.getRow = function(table,index)
{
	if(!table) return null;
	if(index>=0 && index<table.rows.length)return table.rows[index];
	return null;
}

ihelpuoo.dom.getCell = function(row,index)
{
	if(!row) return null;
	if(index>=0 && index<row.cells.length)return row.cells[index];
	return null;
}

ihelpuoo.dom.getCellInTable = function(table,index)
{
	if(!table) return null;
	if(index<0) return null;
	if(table.rows.length==0) return null;
	var w = table.rows[0].cells.length;
	var x = index%w;
	var y = Math.floor(index/w);
	var row = ihelpuoo.dom.getRow(table,y);
	return ihelpuoo.dom.getCell(row,x); 
}

ihelpuoo.dom.contains = function(ele,child)
{
	if(null==ele || null==child) return false;
	if(ele.nodeType != 1) return false;
	for(var node in ele.childNodes)
	{
		if(node==child) return true;
	}
	return false;
}

ihelpuoo.dom.hideChildren = function(ele)
{
	if(null==ele)return;
	if(ele.nodeType!=1)return;
	for(var i=0;i<ele.childNodes.length;i++)
	{
		var node = ele.childNodes.item(i);
		if(node.nodeType==1)
			node.style.display="none";
	}	
}

ihelpuoo.dom.showElement = function(ele)
{
	if("TD"==ele.tagName)
		if(isIE)
			ele.style.display = "block";
		else
			ele.style.display = "table-cell";
	else if("P,DIV,BLOCKQUOTE,UL,OL,TABLE".indexOf(ele.tagName)>-1)
		ele.style.display = "block";
	else
		ele.style.display = "inline";
}

ihelpuoo.dom.disableElement = function(ele)
{
	if(null==ele)return;
	ele.disabled = true;
	if(ele.tagName=="INPUT" || ele.tagName=="TEXTAREA" || ele.tagName=="SELECT")
	{
		ele.style.backgroundColor="#EFEDEE";
		ele.style.color="#999999";
	}
}

ihelpuoo.dom.enableElement = function(ele)
{
	if(null==ele)return;
	ele.disabled = false;
	if(ele.tagName=="INPUT" || ele.tagName=="TEXTAREA" || ele.tagName=="SELECT")
	{
		ele.style.backgroundColor="";
		ele.style.color="";
	}	
}

ihelpuoo.dom.clearAllChildren = function(ele)
{
	if(!ele)return;
	ele.innerHTML = "";
}

ihelpuoo.dom.autoSetObject = function(ele,s)
{
	if(null==ele)return;
	if(null==s)
		s = "";
	else if(!ihelpuoo.isString(s))
	{
		s = s.toString();
	}
	if(ele.tagName=="INPUT" || ele.tagName=="TEXTAREA" || ele.tagName=="SELECT")
		ele.value = s;
	else
		ele.innerHTML = ihelpuoo.escapeInnerHTMLString(s);
}

ihelpuoo.dom.autoGetString = function(ele)
{
	if(null==ele) return null;
	if(ele.tagName=="INPUT" || ele.tagName=="TEXTAREA" || ele.tagName=="SELECT")
		return ele.value;
	else
		return ihelpuoo.trim(ele.innerHTML.toString());
}

ihelpuoo.dom.getContentDocument = function(iframe)
{
	if(!iframe || !iframe.tagName || iframe.tagName!="IFRAME") return null;
	if(isIE)
		return iframe.contentWindow.document;
	else
		return iframe.contentDocument;
}

ihelpuoo.dom.getContentWindow = function(iframe)
{
	if(!iframe || !iframe.tagName || iframe.tagName!="IFRAME") return null;
	if(isIE)
		return iframe.contentWindow;
	else
		return iframe.contentDocument.defaultView;
}

ihelpuoo.dom.getSubFrames = function(iframe)
{
	if(!iframe || !iframe.tagName || iframe.tagName!="IFRAME") return null;
	if(isIE)
		return iframe.contentWindow.document.frames;
	else
		return iframe.contentDocument.defaultView.frames;
}

ihelpuoo.dom.refreshIFrame = function(iframe)
{
	if(!iframe || !iframe.tagName || iframe.tagName!="IFRAME") return;
	if(isIE)
	{
		iframe.contentWindow.document.location.reload();
	}
	else
	{
		iframe.src = iframe.src;
	}
}